// url?paramname=paramval

// Global Variables
paramString = window.location.search;

// functions to handle parameters
function getParamVal(){
	// NOTE: This routine will not work correctly for
	// cases where a paramString contains more than 
	// one name=value item for the SAME name. This routine
	// will return only the first instance. On the other hand,
	// if the paramString contains 'nam1=val1,val2&nam2=val2'
	// getParamVal('nam1') will return the value 'val1,val2'.
 	// Treat the search string as case insensitive, but 
	// return the value in the original case, of course.  
	var pString; 
	var pName;
 	if (arguments.length < 1) { return null; }
 	else if (arguments.length == 1) {
 		pString = paramString;
 		if (pString == null) { return null;}
 		pName = arguments[0];
 	}
 	else {
 		pString = arguments[0]; pName = arguments[1];
 	}
 
 	var pStringU = pString.toUpperCase();
 	var pNameU = pName.toUpperCase();
 	var pNameLoc = pStringU.indexOf(pNameU);
 	if (pNameLoc == -1) {
 		return (null);	
 	}
 	else {
 		var nxtPLoc = pStringU.indexOf('&',pNameLoc+1);
 		if (nxtPLoc == -1) {
 			nxtPLoc = pStringU.length ;
       		}
 		var pValLoc = pStringU.indexOf('=',pNameLoc+1); 
		if (pValLoc == -1) {return null;} 
		return (pString.substring(pValLoc+1,nxtPLoc));
 	}
}